import { Select } from 'antd';
import React from 'react';

const { Option } = Select;

export default function WSelect(props: any) {
  const { onSave, onChange, type, ...res } = props;

  function handle(value: any) {
    onChange?.(value);
    onSave();
  }

  return (
    <Select {...res} onChange={handle} style={{ width: '100%' }}>
      {Object.entries(type).map(([key, value]: any) => {
        return (
          <Option key={value} value={value}>
            {key}
          </Option>
        );
      })}
    </Select>
  );
}
